﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using log4net;
namespace ZXCompany
{
    // 注意: 有关启用 IIS6 或 IIS7 经典模式的说明，
    // 请访问 http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            //初始设置
            //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            //routes.MapRoute(
            //    "Default", // 路由名称
            //    "{controller}.aspx/{action}/{id}", // 带有参数的 URL
            //    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
            //    //new { controller = "Account", action = "WholeInfo", id = UrlParameter.Optional } // 参数默认值
            //);

            //设置 01
            //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            //routes.MapRoute(
            //"Default",
            //"{controller}.aspx/{action}/{id}",
            //new { controller = "Home", action = "Index", id = "" }
            //);
            //routes.MapRoute(
            //"Root",
            //"",uuu
            //new { controller = "Home", action = "Index", id = "" }
            //);

            // 设置 02
            routes.MapRoute("NoAction", "{controller}.aspx", new { controller = "home", action = "index", id = "" }); //无Action的匹配
            routes.MapRoute("NoID", "{controller}/{action}.aspx", new { controller = "home", action = "index", id = "" }); //无ID的匹配
            routes.MapRoute("Default", "{controller}/{action}/{id}.aspx", new { controller = "home", action = "index", id = "" }); //默认匹配
            routes.MapRoute("Root", "", new { controller = "home", action = "index", id = "" }); //根目录匹配 
        }

        protected void Application_Start()
        {
            log4net.Config.DOMConfigurator.Configure();
            AreaRegistration.RegisterAllAreas();
            RegisterRoutes(RouteTable.Routes);
        }
    }
}
